/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.csm.sim2k11.frontend;

import com.csm.sim2k11.simulator.Configuration;

/**
 *
 * @author Santiago Moreno
 */
public class ConfigurationWindow extends javax.swing.JDialog {

    /**
     * Creates new form ConfigurationWindow
     */
    public ConfigurationWindow() {
        initComponents();
        loadValuesToConfiguration();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblConfiguration = new javax.swing.JLabel();
        pnlDistribuciones = new javax.swing.JPanel();
        lblProbMenu = new javax.swing.JLabel();
        lblProbMenu1 = new javax.swing.JLabel();
        lblProbMenu2 = new javax.swing.JLabel();
        sldProbMenu = new javax.swing.JSlider();
        lblProbCantPersonas = new javax.swing.JLabel();
        lblCantPersonas1 = new javax.swing.JLabel();
        txtCantPersonas1 = new javax.swing.JTextField();
        txtCantPersonas2 = new javax.swing.JTextField();
        lblCantPersonas2 = new javax.swing.JLabel();
        txtCantPersonas3 = new javax.swing.JTextField();
        lblCantPersonas3 = new javax.swing.JLabel();
        txtCantPersonas4 = new javax.swing.JTextField();
        lblCantPersonas4 = new javax.swing.JLabel();
        lblDemoraConsumirComida = new javax.swing.JLabel();
        lblMedia = new javax.swing.JLabel();
        txtDemoraComidaMedia = new javax.swing.JTextField();
        lblVarianza = new javax.swing.JLabel();
        txtDemoraComidaVarianza = new javax.swing.JTextField();
        lblVarianzaHoras = new javax.swing.JLabel();
        pnlConstants = new javax.swing.JPanel();
        lblClientsInterval = new javax.swing.JLabel();
        lblMaxClientsInLine = new javax.swing.JLabel();
        lblTakeOrderTime = new javax.swing.JLabel();
        lblCookingTime = new javax.swing.JLabel();
        lblCookingTimeMenu1 = new javax.swing.JLabel();
        txtClientsInterval = new javax.swing.JTextField();
        txtMaxClientsInLine = new javax.swing.JTextField();
        txtTakeOrderTime = new javax.swing.JTextField();
        txtCookingTimeMenu1 = new javax.swing.JTextField();
        txtCookingTimeMenu2 = new javax.swing.JTextField();
        lblCookingTimeMenu2 = new javax.swing.JLabel();
        lblCookingTimeMinutes = new javax.swing.JLabel();
        lblClientsIntervalMinutes = new javax.swing.JLabel();
        lblTakeOrderMinutes = new javax.swing.JLabel();
        lblMaxLineClients = new javax.swing.JLabel();
        lblDeliverOrderTime = new javax.swing.JLabel();
        txtDeliverOrderTime = new javax.swing.JTextField();
        lblDeliverOrderMinutes = new javax.swing.JLabel();
        btnCancel = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Configuración de SimSoft");
        setModal(true);
        setResizable(false);

        lblConfiguration.setText("Completa los siguientes campos con números para modificar los atributos de las entidades y las variables del sistema.");

        pnlDistribuciones.setBorder(javax.swing.BorderFactory.createTitledBorder("Distribuciones:"));

        lblProbMenu.setText("Probabilidades de Menu:");

        lblProbMenu1.setText("P(M1): 0.50");

        lblProbMenu2.setText("P(M1): 0.50");

        sldProbMenu.setMaximum(99);
        sldProbMenu.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                sldProbMenuPropertyChange(evt);
            }
        });

        lblProbCantPersonas.setText("Probabilidad de Cantidad de Personas:");

        lblCantPersonas1.setText("1:");

        txtCantPersonas1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtCantPersonas1.setText("0.25");

        txtCantPersonas2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtCantPersonas2.setText("0.25");

        lblCantPersonas2.setText("2:");

        txtCantPersonas3.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtCantPersonas3.setText("0.25");

        lblCantPersonas3.setText("3:");

        txtCantPersonas4.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtCantPersonas4.setText("0.25");

        lblCantPersonas4.setText("4:");

        lblDemoraConsumirComida.setText("Demora en Consumir la Comida (Distr. Normal):");

        lblMedia.setText("Media:");

        txtDemoraComidaMedia.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtDemoraComidaMedia.setText("1");
        txtDemoraComidaMedia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDemoraComidaMediaActionPerformed(evt);
            }
        });

        lblVarianza.setText("horas    Varianza:");

        txtDemoraComidaVarianza.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtDemoraComidaVarianza.setText("20");

        lblVarianzaHoras.setText("minutos");

        javax.swing.GroupLayout pnlDistribucionesLayout = new javax.swing.GroupLayout(pnlDistribuciones);
        pnlDistribuciones.setLayout(pnlDistribucionesLayout);
        pnlDistribucionesLayout.setHorizontalGroup(
            pnlDistribucionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDistribucionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDistribucionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDistribucionesLayout.createSequentialGroup()
                        .addComponent(lblProbMenu)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblProbMenu1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sldProbMenu, javax.swing.GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblProbMenu2))
                    .addGroup(pnlDistribucionesLayout.createSequentialGroup()
                        .addGroup(pnlDistribucionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlDistribucionesLayout.createSequentialGroup()
                                .addComponent(lblProbCantPersonas)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblCantPersonas1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtCantPersonas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(14, 14, 14)
                                .addComponent(lblCantPersonas2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtCantPersonas2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(14, 14, 14)
                                .addComponent(lblCantPersonas3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtCantPersonas3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(14, 14, 14)
                                .addComponent(lblCantPersonas4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtCantPersonas4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlDistribucionesLayout.createSequentialGroup()
                                .addComponent(lblDemoraConsumirComida)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblMedia)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtDemoraComidaMedia, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblVarianza)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtDemoraComidaVarianza, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblVarianzaHoras)))
                        .addGap(0, 91, Short.MAX_VALUE)))
                .addContainerGap())
        );
        pnlDistribucionesLayout.setVerticalGroup(
            pnlDistribucionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDistribucionesLayout.createSequentialGroup()
                .addGroup(pnlDistribucionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(sldProbMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlDistribucionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblProbMenu)
                        .addComponent(lblProbMenu1)
                        .addComponent(lblProbMenu2)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDistribucionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblProbCantPersonas)
                    .addComponent(lblCantPersonas1)
                    .addComponent(txtCantPersonas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCantPersonas2)
                    .addComponent(txtCantPersonas2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCantPersonas3)
                    .addComponent(txtCantPersonas3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCantPersonas4)
                    .addComponent(txtCantPersonas4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDistribucionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDemoraConsumirComida)
                    .addComponent(lblMedia)
                    .addComponent(txtDemoraComidaMedia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblVarianza)
                    .addComponent(txtDemoraComidaVarianza, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblVarianzaHoras)))
        );

        pnlConstants.setBorder(javax.swing.BorderFactory.createTitledBorder("Constantes:"));

        lblClientsInterval.setText("Intervalo de Llegada de Clientes:");

        lblMaxClientsInLine.setText("Máximo de Clientes en Cola:");

        lblTakeOrderTime.setText("Tiempo de Toma de Pedido:");

        lblCookingTime.setText("Tiempo de Cocina:");

        lblCookingTimeMenu1.setText("Menu 1:");

        txtClientsInterval.setText("10");

        txtMaxClientsInLine.setText("1");

        txtTakeOrderTime.setText("1");

        txtCookingTimeMenu1.setText("10");
        txtCookingTimeMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCookingTimeMenu1ActionPerformed(evt);
            }
        });

        txtCookingTimeMenu2.setText("18");
        txtCookingTimeMenu2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCookingTimeMenu2ActionPerformed(evt);
            }
        });

        lblCookingTimeMenu2.setText("minutos     Menu 2:");

        lblCookingTimeMinutes.setText("minutos");

        lblClientsIntervalMinutes.setText("minutos");

        lblTakeOrderMinutes.setText("minutos");

        lblMaxLineClients.setText("clientes");

        lblDeliverOrderTime.setText("Tiempo de Entrega de Pedido:");

        txtDeliverOrderTime.setText("1");

        lblDeliverOrderMinutes.setText("minutos");

        javax.swing.GroupLayout pnlConstantsLayout = new javax.swing.GroupLayout(pnlConstants);
        pnlConstants.setLayout(pnlConstantsLayout);
        pnlConstantsLayout.setHorizontalGroup(
            pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlConstantsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblDeliverOrderTime)
                    .addComponent(lblCookingTime)
                    .addComponent(lblTakeOrderTime)
                    .addComponent(lblMaxClientsInLine)
                    .addComponent(lblClientsInterval))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlConstantsLayout.createSequentialGroup()
                        .addComponent(lblCookingTimeMenu1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtCookingTimeMenu1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(3, 3, 3)
                        .addComponent(lblCookingTimeMenu2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtCookingTimeMenu2, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(3, 3, 3)
                        .addComponent(lblCookingTimeMinutes))
                    .addGroup(pnlConstantsLayout.createSequentialGroup()
                        .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtTakeOrderTime)
                            .addComponent(txtMaxClientsInLine)
                            .addComponent(txtClientsInterval, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lblClientsIntervalMinutes)
                                .addComponent(lblMaxLineClients, javax.swing.GroupLayout.Alignment.TRAILING))
                            .addComponent(lblTakeOrderMinutes, javax.swing.GroupLayout.Alignment.TRAILING)))
                    .addGroup(pnlConstantsLayout.createSequentialGroup()
                        .addComponent(txtDeliverOrderTime, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblDeliverOrderMinutes)))
                .addContainerGap(205, Short.MAX_VALUE))
        );
        pnlConstantsLayout.setVerticalGroup(
            pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlConstantsLayout.createSequentialGroup()
                .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblClientsInterval)
                    .addComponent(txtClientsInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblClientsIntervalMinutes))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblMaxClientsInLine)
                    .addComponent(txtMaxClientsInLine, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblMaxLineClients))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTakeOrderTime)
                    .addComponent(txtTakeOrderTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblTakeOrderMinutes))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCookingTime)
                    .addComponent(lblCookingTimeMenu1)
                    .addComponent(txtCookingTimeMenu1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCookingTimeMenu2)
                    .addComponent(txtCookingTimeMenu2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCookingTimeMinutes))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlConstantsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDeliverOrderTime)
                    .addComponent(txtDeliverOrderTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblDeliverOrderMinutes)))
        );

        btnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/cancel.png"))); // NOI18N
        btnCancel.setMnemonic('c');
        btnCancel.setText("Cancelar");
        btnCancel.setToolTipText("No guardar los cambios");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/disk.png"))); // NOI18N
        btnSave.setMnemonic('g');
        btnSave.setText("Guardar");
        btnSave.setToolTipText("Guardar los cambios");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlDistribuciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblConfiguration)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(pnlConstants, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 636, Short.MAX_VALUE)
                        .addComponent(btnSave)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCancel)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblConfiguration)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlDistribuciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlConstants, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancel)
                    .addComponent(btnSave))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-844)/2, (screenSize.height-443)/2, 844, 443);
    }// </editor-fold>//GEN-END:initComponents

    private void saveValuesToConfiguration() throws NumberFormatException {
        //Distributions
        Configuration.setPM2(sldProbMenu.getValue()/100d);
        Configuration.getPCP()[0]=Double.valueOf(txtCantPersonas1.getText());
        Configuration.getPCP()[1]=Double.valueOf(txtCantPersonas2.getText());
        Configuration.getPCP()[2]=Double.valueOf(txtCantPersonas3.getText());
        Configuration.getPCP()[3]=Double.valueOf(txtCantPersonas4.getText());
        Configuration.setLunchMedia(Double.valueOf(txtDemoraComidaMedia.getText()));
        Configuration.setLunchVariance(Double.valueOf((txtDemoraComidaVarianza.getText())));
        
        //Constants
        Configuration.setIntervalComing(Double.valueOf(txtClientsInterval.getText()));
        Configuration.setCantCola(Integer.valueOf(txtMaxClientsInLine.getText()));
        Configuration.setTimeOrder(Double.valueOf(txtTakeOrderTime.getText()));
        Configuration.setTimeDeliver(Double.valueOf(txtDeliverOrderTime.getText()));
        Configuration.setTM1(Double.valueOf(txtCookingTimeMenu1.getText()));
        Configuration.setTM2(Double.valueOf(txtCookingTimeMenu2.getText()));
        
        //Stadistics
        Configuration.getHistoricResults().clear();
    }
    
    private void loadValuesToConfiguration() throws NumberFormatException {
        //Distributions
        sldProbMenu.setValue((int)(Configuration.getPM2()*100));
        txtCantPersonas1.setText(String.valueOf(Configuration.getPCP()[0]));
        txtCantPersonas2.setText(String.valueOf(Configuration.getPCP()[1]));
        txtCantPersonas3.setText(String.valueOf(Configuration.getPCP()[2]));
        txtCantPersonas4.setText(String.valueOf(Configuration.getPCP()[3]));
        txtDemoraComidaMedia.setText(String.valueOf(Configuration.getLunchMedia()));
        txtDemoraComidaVarianza.setText(String.valueOf(Configuration.getLunchVariance()));
        
        //Constants
        txtClientsInterval.setText(String.valueOf(Configuration.getIntervalComing()));
        txtMaxClientsInLine.setText((String.valueOf(Configuration.getCantCola())));
        txtTakeOrderTime.setText(String.valueOf(Configuration.getTimeOrder()));
        txtDeliverOrderTime.setText(String.valueOf(Configuration.getTimeDeliver()));
        txtCookingTimeMenu1.setText(String.valueOf(Configuration.getTM1()));
        txtCookingTimeMenu2.setText(String.valueOf(Configuration.getTM2()));
    }

    private void txtDemoraComidaMediaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDemoraComidaMediaActionPerformed
        
    }//GEN-LAST:event_txtDemoraComidaMediaActionPerformed

    private void txtCookingTimeMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCookingTimeMenu1ActionPerformed
        
    }//GEN-LAST:event_txtCookingTimeMenu1ActionPerformed

    private void txtCookingTimeMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCookingTimeMenu2ActionPerformed
        
    }//GEN-LAST:event_txtCookingTimeMenu2ActionPerformed

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCancelActionPerformed

    private void sldProbMenuPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_sldProbMenuPropertyChange
        int decimals=(int) Math.pow(10,2);
        lblProbMenu2.setText("P(M2): "+Math.rint((sldProbMenu.getValue()/100d)*decimals)/decimals);
        lblProbMenu1.setText("P(M1): "+Math.rint((1-sldProbMenu.getValue()/100d)*decimals)/decimals);
    }//GEN-LAST:event_sldProbMenuPropertyChange

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        saveConfiguration();
        dispose();
    }//GEN-LAST:event_btnSaveActionPerformed

    private void saveConfiguration()
    {
        //TODO: Validate the info to save
        saveValuesToConfiguration();        
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnSave;
    private javax.swing.JLabel lblCantPersonas1;
    private javax.swing.JLabel lblCantPersonas2;
    private javax.swing.JLabel lblCantPersonas3;
    private javax.swing.JLabel lblCantPersonas4;
    private javax.swing.JLabel lblClientsInterval;
    private javax.swing.JLabel lblClientsIntervalMinutes;
    private javax.swing.JLabel lblConfiguration;
    private javax.swing.JLabel lblCookingTime;
    private javax.swing.JLabel lblCookingTimeMenu1;
    private javax.swing.JLabel lblCookingTimeMenu2;
    private javax.swing.JLabel lblCookingTimeMinutes;
    private javax.swing.JLabel lblDeliverOrderMinutes;
    private javax.swing.JLabel lblDeliverOrderTime;
    private javax.swing.JLabel lblDemoraConsumirComida;
    private javax.swing.JLabel lblMaxClientsInLine;
    private javax.swing.JLabel lblMaxLineClients;
    private javax.swing.JLabel lblMedia;
    private javax.swing.JLabel lblProbCantPersonas;
    private javax.swing.JLabel lblProbMenu;
    private javax.swing.JLabel lblProbMenu1;
    private javax.swing.JLabel lblProbMenu2;
    private javax.swing.JLabel lblTakeOrderMinutes;
    private javax.swing.JLabel lblTakeOrderTime;
    private javax.swing.JLabel lblVarianza;
    private javax.swing.JLabel lblVarianzaHoras;
    private javax.swing.JPanel pnlConstants;
    private javax.swing.JPanel pnlDistribuciones;
    private javax.swing.JSlider sldProbMenu;
    private javax.swing.JTextField txtCantPersonas1;
    private javax.swing.JTextField txtCantPersonas2;
    private javax.swing.JTextField txtCantPersonas3;
    private javax.swing.JTextField txtCantPersonas4;
    private javax.swing.JTextField txtClientsInterval;
    private javax.swing.JTextField txtCookingTimeMenu1;
    private javax.swing.JTextField txtCookingTimeMenu2;
    private javax.swing.JTextField txtDeliverOrderTime;
    private javax.swing.JTextField txtDemoraComidaMedia;
    private javax.swing.JTextField txtDemoraComidaVarianza;
    private javax.swing.JTextField txtMaxClientsInLine;
    private javax.swing.JTextField txtTakeOrderTime;
    // End of variables declaration//GEN-END:variables
}
